package com.dinnerwithfriends.client.interests;

import com.dinnerwithfriends.client.GWTEntryPoint;
import com.dinnerwithfriends.client.authentication.facebook.FacebookImage;
import com.dinnerwithfriends.client.model.User;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;

public class ShowInterests extends VerticalPanel {

	public static VerticalPanel panelInterests = new VerticalPanel();

	public ShowInterests() {

		this.clear();

		HTML interest = new HTML("<b>Friends Common Interests</b>");

		interest.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {

				show();
			}
		});

		this.add(interest);

		panelInterests.setWidth("200px");

		panelInterests.setSpacing(10);

		panelInterests.clear();

		this.add(panelInterests);
	}

	public static void show() {

		panelInterests.clear();

		/*
		 * if (GWTEntryPoint.facebookUser != null) {
		 * 
		 * String myImage = FacebookImage.getString(
		 * GWTEntryPoint.facebookUser.getFacebookID(),
		 * GWTEntryPoint.facebookUser.getFacebookName());
		 * 
		 * panelInterests.add(new HTML("<br><br>" + myImage + " <b>" +
		 * GWTEntryPoint.facebookUser.getFacebookName() + "</b><br>" +
		 * GWTEntryPoint.facebookFriends.get(
		 * GWTEntryPoint.facebookUser.getFacebookID())
		 * .getFacebookInterests())); }
		 */

		for (User friend : GWTEntryPoint.facebookFriends.values()) {

			if (!friend.getFacebookID().equals(
					GWTEntryPoint.facebookUser.getFacebookID())
					&& friend.getFacebookInterests() != null) {

				String image = FacebookImage.getString(friend.getFacebookID(),
						friend.getFacebookName());

				panelInterests.add(new HTML("<br><br>" + image + " <b>"
						+ friend.getFacebookName() + "</b><br>"
						+ friend.getFacebookInterests()));
			}
		}
	}
}
